#ifndef __CHARCONVERT__
#define __CHARCONVERT__

#pragma once

#include "UnicodeMethod.h"

class CUnicodeToAnsi
{
public:
	CUnicodeToAnsi(LPCWSTR pszIn, const BOOL& bNullTerminated = TRUE);
    CUnicodeToAnsi();
	~CUnicodeToAnsi();

public:
	void    operator=(LPCWSTR pszIn);
	const   char* GetPtr () const { if (m_pStrPtr == NULL) return ""; else return m_pStrPtr; }
	const   char* Convert(LPCWSTR pszIn, const BOOL& bNullTerminated = TRUE);
    int     GetLength() { return m_iOut; };

private:
	const   char* m_pStrPtr;
	int     m_iOut;
    BOOL    m_bNullTerminated;
};

class CAnsiToUnicode
{
public:
	CAnsiToUnicode(const char* pszIn, const BOOL& bNullTerminated = TRUE);
	CAnsiToUnicode();
	~CAnsiToUnicode();

public:
	void    operator=(const char* pszIn);
    LPCWSTR GetPtr   () const { if (m_pStrPtr == NULL) return L""; else return m_pStrPtr; }
	LPCWSTR Convert  (const char* pszIn, const BOOL& bNullTerminated = TRUE);
    int     GetLength() { return m_iOut; };

private:
	LPCWSTR m_pStrPtr;
	int     m_iOut;
    BOOL    m_bNullTerminated;
};

class CUTF16ToUTF8
{
public:
	CUTF16ToUTF8(LPCWSTR pszIn, const BOOL& bNullTerminated = TRUE);
	CUTF16ToUTF8();
	~CUTF16ToUTF8();

public:
	void    operator=(LPCWSTR pszIn);
	const   char* GetPtr () const { if (m_pStrPtr == NULL) return ""; else return m_pStrPtr; }
	const   char* Convert(LPCWSTR pszIn, const BOOL& bNullTerminated = TRUE);
    int     GetLength() { return m_iOut; };

private:
	const   char* m_pStrPtr;
	int     m_iOut;
    BOOL    m_bNullTerminated;
};

class CUTF8ToUTF16
{
public:
	CUTF8ToUTF16(const char* pszIn, const BOOL& bNullTerminated = TRUE);
	CUTF8ToUTF16();
	~CUTF8ToUTF16();

public:
	void    operator=(const char* pszIn);
	LPCWSTR GetPtr   () const { if (m_pStrPtr == NULL) return L""; else return m_pStrPtr; }
	LPCWSTR Convert  (const char* pszIn, const BOOL& bNullTerminated = TRUE);
    int     GetLength() { return m_iOut; };

private:
	LPCWSTR m_pStrPtr;
	int     m_iOut;
    BOOL    m_bNullTerminated;
};
#endif

